Home | What's new | What's popular | Forums | Newsletter | ASP Links | Link here! | Advertise | Contact
ASPCode.net
The place to find free ASP code
 Home : Site statistics : What are your visitors doing on your site?

Search for

Applications(151)

Code snippets(167)

Information and tips(14)

Free ASP hosts(17)

Guest script area (1)

Projects (1)

Other stuff

Site network
SQLExperts.com
AdMentor

What are your visitors doing on your site?

Logging system that lets you keep track of what your visitors are doing ( or not doing ) at your site

Current version: n/a
Written by: ASPCode.net
Submitted date: 2000-03-02


So, you have spent X hours( or days ) implementing a certain
function ( lets say a recommend script ) at your website. You upload it,
test it and
see it's working. You feel great, don't you? Now, I bet, just the very
next day, you are very curious to see if it became the success you really
thought it would be. Now, how do you measure it?

What I will give you here is some simple ( so simple it's nearly
embarassing... ) functions
you can use to log just anything you'd like: How many visitors have used
the recommend service and which pages got recommended, how many have
clicked on a certain button - you name it.

First we will need a database, let's use an Access database for simplicity.
Create a table called LOGACTION and add four columns:

- id AutoNumber
- actionid text(50)
- description text(255)
- when datetime

The id is just an autonumbering field.
actionid will be used as an category specifier. Like 'recommend' or
'buttonclick'
description will be used as a more descriptive text, you could for example
add the actual page where the action took place ( using HTTP_REFERER ) or
whoch specific page was recommended etc
when is of course a timestamp


Next, create a file called logaction.asp
Edit it like this:

<% Public Sub LogAction ( sCategory, sText ) Dim oConn Dim oRS Set oConn = Server.CreateObject("ADODB.Connection") oConn.Open "change-to-point-to-your-database" Set oRS = Server.CreateObject("ADODB.Recordset") oRS.Open "select * from logaction where id=-1 " ,oConn ,1,3 oRS.AddNew oRS("actionid") = sCategory oRS("description") = sText oRS("when") = Now() oRS.Update oRS.Close oConn.Close End Sub %>

Now, all you have to do is include the file
<!--#include file="logaction.asp"-->
and call LogAction, for example in a sendmail.asp which is used for site
recommendation:
****
LogAction "recommend", sThePage
***

Reporting function: How can we see what actions has took place?
Create a file called view.asp and edit it like this:
<html> <head> <title>Action viewer</title> </head> <body> <table border="0" width="100%"> <tr> <td width="33%"><a href="view.asp?sort=actionid">Category</a></td> <td width="33%"><a href="view.asp?sort=description">Text</a></td> <td width="34%"><a href="view.asp?sort=when+desc">When</a></td> </tr> <% Dim oConn Dim oRS Dim strSort strSort = "when" If Request.QueryString("sort") <> "" Then strSort = Request.QueryString("sort") End If Set oConn = Server.CreateObject("ADODB.Connection") oConn.Open "change-to-point-to-your-database" Set oRS = oConn.Execute("select * from logaction order by " & strSort ) While Not oRS.EOF %> <tr> <td width="33%"><%=oRS("actionid")%></td> <td width="33%"><%=oRS("description")%></td> <td width="34%"><%=oRS("when")%></td> </tr> <% oRS.MoveNext Wend %> </table> </body> </html>

Now we have a simple report function which you also let you sort by date,
action etc.





 

COMMENTS:

Where can I find the code? --- Christian (3/6/2000 5:00:27 AM)
It is in the article --- Stefan Holmberg (3/6/2000 9:49:53 AM)
not very clear --- Thomas Whalen (3/6/2000 12:41:52 PM)
Mistyping of action/logaction --- Stefan Holmberg (3/6/2000 4:24:12 PM)
Great Idea! --- peter (3/7/2000 3:01:06 AM)
where do i put LogAction? --- Titi Camara (3/14/2000 9:29:20 PM)
where do i put LogAction? --- Titi Camara (3/14/2000 9:29:56 PM)
Nice...short and sweet --- John (4/17/2000 11:56:28 AM)
Having problems? --- Mike Knowles (5/24/2000 4:34:09 PM)
yuiyuiyui --- jhkjhk (5/30/2000 8:11:16 AM)

[ Write comment ]

AD

SPONSORS

It's free
Try it free for 3 months


 

Copyright ©  2000 Stefan Holmberg. All rights reserved.  Privacy Statement.